package chapter02

import java.io.{File, PrintWriter}
import scala.io.Source

/**
 * Created with IntelliJ IDEA.
 * ClassName: Test06_FileIO
 * Package: chapter02
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 *          Date: 2023-06-17
 *          Time: 14:49
 */

//文件的输入输出
object Test06_FileIO {
  def main(args: Array[String]): Unit = {
    //1.从文件读取数据
    Source.fromFile("src/main/resources/test.txt").foreach(print)


    //从数据写入文件 Scala没有专门写的类 调用Java当中的
    val writer = new PrintWriter(new File("src/main/resources/output.txt"))
    writer.write("hello scala form java writer")
    writer.close()

  }
}
